package ${package.Service};

import ${package.Entity}.${entity};
import ${superServiceClassPackage};
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${package.Entity}.request.Find${entity}ByPageReq;
import ${package.Entity}.request.Find${entity}ListReq;
import ${package.Entity}.request.Del${entity}Req;
import ${package.Entity}.request.BatchDelete${entity}Req;
import java.util.List;
import java.util.Map;

/**
 * ${table.comment!} 仓库接口
 *
 * @author ${author}
 * @since ${date}
 */
<#if kotlin>
interface ${table.serviceName} : ${superServiceClass}<${entity}>
<#else>
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {

    /**
     * 分页查询${table.comment!}列表
     *
     * @param req 查询条件
     * @return 分页数据
     */
    Page<${entity}> find${entity}ByPage(Find${entity}ByPageReq req);
    
    /**
     * 查询${table.comment!}列表
     *
     * @param req 查询条件
     * @return 列表数据
     */
    List<${entity}> find${entity}ListByCondition(Find${entity}ListReq req);
    
    /**
     * 新增${table.comment!}
     *
     * @param ${entity?uncap_first} ${table.comment!}对象
     */
    void add${entity}(${entity} ${entity?uncap_first});
    
    /**
     * 修改${table.comment!}
     *
     * @param ${entity?uncap_first} ${table.comment!}对象
     */
    void mod${entity}(${entity} ${entity?uncap_first});
    
    /**
     * 删除${table.comment!}
     *
     * @param req 删除条件
     */
    void del${entity}ById(Del${entity}Req req);
    
    <#-- 检查主键字段数量，用于判断是单主键还是联合主键 -->
    <#assign primaryKeyCount = 0>
    <#if table?? && table.fields??>
    <#list table.fields as field>
        <#if field.keyFlag?? && field.keyFlag>
            <#assign primaryKeyCount = primaryKeyCount + 1>
        </#if>
    </#list>
    </#if>
    
    <#-- 仅为单主键表生成批量删除方法 -->
    <#if primaryKeyCount == 1 || !(table?? && table.fields??)>
    /**
     * 批量删除${table.comment!}
     *
     * @param req 删除条件
     */
    void batchDelete${entity}(BatchDelete${entity}Req req);
    </#if>

    /**
     * 按条件删除${table.comment!}
     *
     * @param conditionMap 条件字段和值
     * @return 删除的记录数
     */
    int del${entity}ByCondition(Map<String, Object> conditionMap);
}
</#if> 